import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '../views/Login.vue'
import Register from '../views/Register'
import Content from "../views/Content";

const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err);
}
Vue.use(VueRouter)

const routes = [
    {
        path: "/",
        redirect: '/home',
        meta: {
          title: "Forum"
        }
    },
    {
        path: "/login",
        name: "Login",
        component: Login,
        meta: {
          title: "登录"
        }
    },
    {
      path: "/register",
      name: "Register",
      component: Register,
      meta: {
        title: "注册"
      }
    },
    {
        path: "/home",
        name: "Home",
        component: Content,
        meta: {
            title: "主页"
        }
    },
]

const router = new VueRouter({
    mode: 'history',
    base: process.env.BASE_URL,
    routes
  })
  
export default router